<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="jquery-3.7.1.slim.min.js"></script>
</head>
<body>
    <button id="reset">重新开始一局游戏</button><br>
    <span>请输入要猜的数字：<input type="text" id="number"> <button id = "guess">猜</button></span><br>
    <span>已经猜的次数：</span><span id="count">0</span><br>
    <span id=>结果：</span><span id="result"></span>

    <script>
        let number = Math.floor(Math.random()*100)+1;
        let count = 0;
        console.log(number);
        $("#guess").click(function(){
            count++;
            let guessnumber = $("#number").val();
            $("#count").text(count);
            if(guessnumber>number){
                $("#result").text("猜大了");
                $("#result").css("color","red");
            }else if(guessnumber<number){
                $("#result").text("猜小了");
                $("#result").css("color","red");
            }else{
                $("#result").text("猜对了");
                $("#result").css("color","green");
            }
        })
        $("#reset").click(function(){
            $("#result").text("");
            let number = Math.floor(Math.random()*100)+1;
            let count = 0;
            console.log(number);
            $("#count").text(count);
           $("#number").val("");

        })
        
    </script>
</body>
</html>